<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="d" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript" src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>"/>
<link rel="stylesheet" href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
$(".xinz_skill").linkbutton({
	onClick:function(){
		$("#w4_duty").dialog("open");
	}
});

//删除
$(".sc_wdm_duty").linkbutton({onClick:function(){
	var rowInfo = $("#yglz_wdm_duty").datagrid('getSelected');
	if(rowInfo){
		$.messager.confirm('确认', '您确定要删除该条数据吗？', function(v){
			if(v){
				var dutyId = $("#yglz_wdm_duty").datagrid("getSelected").dutyId;
				$.getJSON("delete_duty",{dutyId:dutyId},function(v){
					if(v){
						$('#yglz_wdm_duty').datagrid('reload');   
					}else{
						$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
					}
				});
			}
			
		});
	}else{
		$.messager.alert('错误', '对不起，操作失败，没有选中的行');
	}
	
}});
//编辑
$(".jz_wdm_duty").linkbutton({onClick:function(){
	var rowInfo = $("#yglz_wdm_duty").datagrid('getSelected');
	if(rowInfo){
		var dutyId = $("#yglz_wdm_duty").datagrid("getSelected").dutyId;
		var dutyName = $("#yglz_wdm_duty").datagrid("getSelected").dutyName;
		
		$("#win2_skill").dialog("open");
		$('#reasons_for_leaving_duty2').form('load','load_duty?dutyId='+dutyId);
		
	}else{
		$.messager.alert('错误', '对不起，操作失败，没有选中的行');
	}
	
}});
//模糊查询
function doSearch(value,name){
	$('.yglz_wdm_duty').datagrid({ url: 'modaddSeslect_duty?text='+value});//重新指定url
    $('.yglz_wdm_duty').datagrid('load',{  
   		
    });

}




</script>
	<table id="yglz_wdm_duty" class="easyui-datagrid yglz_wdm_duty" data-options="
				url:'queryByPage_duty',
				pageList:[2,4,6,8,10],
				pageSize:10,
				pagination:true,
				method:'get',
				fitColumns:true,
				fit:true,
				nowrap:false,
				autoRowHeight:true,
				singleSelect:true,
				striped:true,
				toolbar:'#wdm15_duty'
				">
			<thead>
				<tr>
					<th data-options="field:'dutyId',width:50,align:'center'">职务编号</th>
					<th data-options="field:'dutyName',width:50,align:'center'">职务名称</th>
					<th data-options="field:'dutyPerson',width:50,align:'center'">创建者</th>
					<th data-options="field:'dutyCreatordate',width:50,align:'center',
							formatter:function(value,row,index){
							var date = new Date(value);
							return date.toLocaleString();
					}
					">创建日期</th>
					<th data-options="field:'dutyUpdatedate',width:50,align:'center',
							formatter:function(value,row,index){
							var date = new Date(value);
							return date.toLocaleString();
					}
					">更新日期</th>
					
				</tr> 
			</thead>
			<tbody>
			</tbody>
		</table>
		<d:g id="26">
		<div id="wdm15_duty">
					<a href="#" class="xinz_skill" data-options="iconCls:'icon-add',plain:true,text:'新增',iconAlign:'left'"></a>| 
                <a href="#" class="easyui-linkbutton jz_wdm_duty" data-options="iconCls:'icon-edit',plain:true,text:'编辑',iconAlign:'left'"></a>| 
                <a href="#" class="easyui-linkbutton sc_wdm_duty" id="sc_wdm_duty" data-options="iconCls:'icon-remove',plain:true,text:'删除',iconAlign:'left'"></a>| 
				搜索内容
				<input id="ss" class="easyui-searchbox sousuo"
						searcher="doSearch" prompt="请输入职务名"
						style="width: 200px; vertical-align: middle;"></input> 
	</div>

	</d:g>	
		<div id="w4_duty" class="easyui-dialog"
			data-options="width:500,
						height:150,
						title:'定义职务',
						modal:true,
						closed:true,
						buttons:[{
					text:'添加',
					iconCls:'icon-ok',
					handler:function(){
							$('#reasons_for_leaving_duty').form({
							onSubmit:function(params){
								return $('#reasons_for_leaving_duty').form('validate');
							},success:function(v){
								v=eval('('+ v + ')');
								if(v.success){
								
									$('#w4_duty').dialog('close');
									$('#yglz_wdm_duty').datagrid('reload');
									$('#reasons_for_leaving_duty').form('reset');
								}else{
									$.messager.alert('错误', v.message);
								}
							}
						
						}).submit();
					}
				},{
					text:'取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#w4_duty').dialog('close');
					}
				}]">
	 		<form action="insert_duty" method="post"  id="reasons_for_leaving_duty">
				<div style="margin-left:60px;margin-top:10px;">*职务名称：<input class="easyui-textbox" id="dutyName" name="dutyName" data-options="width:'80%',required:true"/></div>
			</form>
		</div>
			
			
			
		<div id="win2_skill" class="easyui-dialog"
			data-options="width:500,
						height:190,
						title:'定义职务',
						modal:true,
						closed:true,
						buttons:[{
					text:'添加',
					iconCls:'icon-ok',
					handler:function(){
						$('#reasons_for_leaving_duty2').form({
							onSubmit:function(params){
								return $('#reasons_for_leaving_duty2').form('validate');
							},success:function(v){
								v=eval('('+ v + ')');
								if(v.success){
									$('#win2_skill').dialog('close');
									$('#yglz_wdm_duty').datagrid('reload');
									$('#reasons_for_leaving_duty2').form('reset');
								}else{
									$.messager.alert('错误', v.message);
								}
							}
						
						}).submit();
					}
				},{
					text:'取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#win2_skill').dialog('close');
					}
				}]">
	 		<form action="update_duty" method="post"  id="reasons_for_leaving_duty2" >
	 			<div style="margin-left:60px;margin-top:10px;">*职务编号：<input class="easyui-textbox" id="dutyId" name="dutyId" data-options="width:'80%',readonly:true"/></div>
				<div style="margin-left:60px;margin-top:10px;">*职务名称：<input class="easyui-textbox" id="dutyName" name="dutyName" data-options="width:'80%',required:true"/></div>
			</form>
		</div>			
</body>
</html>